<?php
/**
 * Smart Library - Smart Framework
 * http://smart-framework.highet.eu
 *
 * @category   SmartL
 * @package    SmartL_Zend
 * @subpackage Controller
 * @copyright  Copyright (c) 2005-2008 Smart Framework team - Stepan Sindelar, Vojtech Vit
 * @license    http://www.opensource.org/licenses/bsd-license.php	New BSD License
 */

/**
 * @see SmartL_Zend_Controller_Action_Config_ActionInfo_TranslationInfo
 */
require_once 'SmartL/Zend/Controller/Action/Config/ActionInfo/TranslationInfo.php';
/**
 * @see SmartL_Zend_Controller_Action_Config_ActionInfo_SelectionInfo
 */
require_once 'SmartL/Zend/Controller/Action/Config/ActionInfo/SelectionInfo.php';
/**
 * @see SmartL_Zend_Controller_Action_Config_ActionInfo_CacheInfo
 */
require_once 'SmartL/Zend/Controller/Action/Config/ActionInfo/CacheInfo.php';

/**
 * @uses SmartL_Zend_Controller_Action_Config_ActionInfo_TranslationInfo
 * 
 * @package SmartL_Zend
 * @subpackage Controller
 */
class SmartL_Zend_Controller_Action_Config_ActionInfo {
	private $_translations = array ();
	private $_permissions = array ();
	private $_restrictions = array ();
	private $_selections = array ();
	private $_forms = array ();
	private $_cache = null;
	
	public function setCacheInfo(SmartL_Zend_Controller_Action_Config_ActionInfo_CacheInfo $cache) {
		$this->_cache = $cache;
	}
	
	/**
	 * @return SmartL_Zend_Controller_Action_Config_ActionInfo_CacheInfo
	 */
	public function getCacheInfo() {
		return $this->_cache;
	}
	
	/** 
	 * For setting array of informations of translations.
	 * Index is id of translation.
	 *  
	 * @param array[string]=>SmartL_Zend_Controller_Action_Config_ActionInfo_TranslationInfo $value
	 */
	public function setTranslations(array $value) {
		$this->_translations = $value;
	}
	/**
	 * Returns array with informations of translations given in config.
	 * Index is id of translation.
	 *
	 * @return array[string]=>SmartL_Zend_Controller_Action_Config_ActionInfo_TranslationInfo
	 */
	public function getTranslations() {
		return $this->_translations;
	}
	
	/**
	 * Returns user access permissions for this action.
	 *
	 * @return array Action user access permissions
	 */
	public function getAccessPermissions() {
		return $this->_permissions;
	}
	/**
	 * Sets user access permissions for this action.
	 *
	 * @param array $value New action user access permissions
	 */
	public function setAccessPermissions(array $value) {
		$this->_permissions = $value;
	}
	/**
	 * Returns user access restrictions for this action.
	 *
	 * @return array Action user access restrictions
	 */
	public function getAccessRestrictions() {
		return $this->_restrictions;
	}
	/**
	 * Sets user access restrictions for this action.
	 *
	 * @param array $value New action user access restrictions
	 */
	public function setAccessRestrictions(array $value) {
		$this->_restrictions = $value;
	}
	/**
	 * Returns the configuration of specified web form as an array.     
	 *
	 * @param string $name Form name
	 * @return array Form configuration
	 */
	public function getForm($name) {
		return $this->_forms [$name];
	}
	/**
	 * Sets the configuration of specified web form by an array.   
	 * 
	 * @param array $value Form configuration
	 */
	public function setForms($value) {
		$this->_forms = $value;
	}
	/**
	 * Adds db query selection information to this action configuration.
	 *
	 * @param string $name Selection name
	 * @param SmartL_Zend_Controller_Action_Config_ActionInfo_SelectionInfo $data Selection info
	 */
	public function addSelection($name, SmartL_Zend_Controller_Action_Config_ActionInfo_SelectionInfo $data) {
		$this->_selections [$name] = $data;
	}
	/**
	 * Returns db query selection info by it's name. 
	 * 
	 * @param string $name Selection name
	 * @return SmartL_Zend_Controller_Action_Config_ActionInfo_SelectionInfo Selection info
	 */
	public function getSelection($name) {
		if (! isset ( $this->_selections [$name] )) {
			require_once 'SmartL/Zend/Controller/Action/Config/Exception.php';
			throw new SmartL_Zend_Controller_Action_Config_Exception ( "Selection with name {$name} wasn't found in action config" );
		}
		return $this->_selections [$name];
	}
}